package com.sykj.seaflow.warm.core.replace;

import cn.hutool.core.util.ObjectUtil;
import cn.hutool.extra.spring.SpringUtil;
import com.sykj.seaflow.warm.module.nodeExt.entity.FlowNodeExt;
import com.sykj.seaflow.warm.module.nodeExt.service.FlowNodeExtService;
import com.warm.flow.core.FlowFactory;
import com.warm.flow.core.dto.FlowParams;
import com.warm.flow.core.entity.*;
import com.warm.flow.core.enums.NodeType;
import com.warm.flow.core.service.impl.TaskServiceImpl;
import com.warm.flow.core.utils.CollUtil;
import com.warm.flow.core.utils.StreamUtils;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * 先保留， 这里没有执行， 先看看源码是否还需要调整
 */
public class WarmTaskServiceImpl extends TaskServiceImpl {


    /**
     * 覆盖方法,  如果 网关下面还是网关, 继续递归查询
     * @param flowParams
     * @param node
     * @return
     */
    @Override
    public List<Node> getNextByCheckGateWay(FlowParams flowParams, Node node) {
        List<Node> nodeList = super.getNextByCheckGateWay(flowParams, node);
//        List<Node> actualNextNode = new ArrayList<>();
//        nextNode(flowParams, nodeList, actualNextNode);
        return nodeList;

    }

    public void nextNode(FlowParams flowParams,  List<Node> result, List<Node> actualNextNode ){
        for(Node nextNode : result){
            if(NodeType.isGateWay(nextNode.getNodeType())){
                List<Node> netNode = super.getNextByCheckGateWay(flowParams, nextNode);
                nextNode(flowParams, netNode, actualNextNode);
            }else{
                actualNextNode.add(nextNode);
            }
        }
    }





}
